package com.example.moneygrosService.requests;

import java.util.Arrays;

public class MoneyGrosRequest {
	private static final String TAG = "MoneyGrosRequest";
	
	protected int mRequestType;
	protected String mSrcID;
	protected String mDestID;
	protected String[] mData;
	
	public final String separator="#";
	
	interface REQUEST_TYPE{
		int BALANCE_MODIFICATION_REQ=2;
		int BALANCE_MODIFICATION_ACK=3;
		int PROFILE_PUBLICATION=4;
	}

	public MoneyGrosRequest(String frame){
		parseFrame(frame);
	}

	private void parseFrame(String frame) {
		// TODO Auto-generated method stub
		String[] strArray = frame.trim().split(separator);
		if(strArray.length>4){
			setSrcID(strArray[1]);
			setDestID(strArray[2]);
			setType(Integer.parseInt(strArray[3]));
			setData(Arrays.copyOfRange(strArray, 4, strArray.length-1));
		}
	}

	public String getSrcID(){
		return mSrcID;
	}
	public void setSrcID(String srcID){
		mSrcID = srcID;
	}
	public String getDestID(){
		return mDestID;
	}
	public void setDestID(String destID){
		mDestID = destID;
	}
	
	public int getType(){
		return mRequestType;
	}
	public void setType(int type){
		mRequestType = type;
	}

	public String[] getData(){
		return mData;
	}
	public void setData(String[] data){
		mData = data;
	}
}
